<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">

<head>
  <!--请假-->
  <meta charset="UTF-8">
  <title>根据id获取的详细信息放到这里</title>
  <link rel="stylesheet" href="../layuimini/lib/layui-v2.6.3/css/layui.css" media="all">
  <link rel="stylesheet" href="../layuimini/css/public.css" media="all">
</head>
<body>
<form method="post" class="layui-form" action="">

  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label" style="width:110px">请假人</label>
      <div class="layui-input-inline">
          <input type="text" lay-verify="required" class="layui-input" th:value="${einfo.empName}" readonly="readonly">
          <input type="hidden" name="empid" th:value="${einfo.id}" readonly="readonly">
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label" style="width:110px">请假内容</label>
      <div class="layui-input-inline">
        <textarea name="leavetext" lay-verify="required" class="layui-textarea"></textarea>
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label" style="width:110px">开始时间</label>
      <div class="layui-input-inline">
          <input type="date" lay-verify="required" class="layui-input" name="leavedate1" id="kaishi">
      </div>
    </div>
    <br/>
    <div class="layui-inline">
      <label class="layui-form-label" style="width:110px">结束时间</label>
      <div class="layui-input-inline">
        <input type="date" lay-verify="required" class="layui-input"name="leavedate2" id="jiesu">
      </div>
    </div>
    <br/>
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">提交</button>
      </div>
    </div>
  </div>
</form>
<script src="../layuimini/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
  var $ = layui.jquery;
  $(function () {
    //获取当前时间
    var dateone =new Date();
    //获取当前年份
    var year =dateone.getFullYear();
    //获取当前月份
    var month = dateone.getMonth()+1<10 ? "0"+(dateone.getMonth()+1):(dateone.getMonth()+1);
    //获取下个月份
    var xmonth=dateone.getMonth()+2<10 ? "0"+(dateone.getMonth()+2):(dateone.getMonth()+2);
    //获取当前日期
    var date =dateone.getDate()<10 ? "0"+dateone.getDate():dateone.getDate();

    $("#kaishi").attr("max",year+"-"+xmonth+"-01");
    $("#kaishi").attr("min",year+"-"+month+"-"+date);
    $("#jiesu").attr("max",year+"-"+xmonth+"-01");
    $("#jiesu").attr("min",year+"-"+month+"-"+date);
  })
  layui.use(['form'], function () {
    var form = layui.form;
    var layer = layui.layer;



    //监听提交
    form.on('submit(saveBtn)', function (data) {
      $.post('/attendance/qleave',data.field,function(res){
        if(res.data==="success"){
          var iframeIndex = parent.layer.getFrameIndex(window.name);
          parent.layer.close(iframeIndex);
          //通过父页面去重新加载表格
          parent.layui.table.reload('table-user');
          parent.layer.msg(res.msg);
        }
      })
      var iframeIndex = parent.layer.getFrameIndex(window.name);
      parent.layer.close(iframeIndex);
      return false;
    });
  });
</script>
</body>
</html>